import java.util.Arrays;

public class demo1 {
    public static void main(String[] args) {
        int []nums={0,0,1,1,2,2,2};
        System.out.println(removeDuplicates(nums));
        System.out.println(Arrays.toString(nums));
    }
    public static int removeDuplicates(int[] nums){
        int count =1;
        for (int i = 0; i <nums.length ; i++) {
            if(nums[count-1]!=nums[i]){
                nums[count++]=nums[i];
            }
        }
        return count;

    }
}
